﻿using Gargoyle.Roton;
using System;
using System.Collections.Generic;
using System.Text;

namespace Gargoyle.ZZT
{
    public delegate bool DirectionDelegate(Game g, Thing thing, Pointer offset, Vector vector);

    static class Directions
    {
        public static bool Clockwise(Game g, Thing thing, Pointer offset, Vector vector)
        {
            if (g.ReadDirection(thing, offset, vector))
            {
                vector.CopyFrom(vector.Clockwise());
                return true;
            }
            return false;
        }

        public static bool CounterClockwise(Game g, Thing thing, Pointer offset, Vector vector)
        {
            if (g.ReadDirection(thing, offset, vector))
            {
                vector.CopyFrom(vector.CounterClockwise());
                return true;
            }
            return false;
        }

        public static bool East(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(Vector.East());
            return true;
        }

        public static bool Flow(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(thing.Vector);
            return true;
        }

        public static bool Idle(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(Vector.Idle());
            return true;
        }

        public static bool North(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(Vector.North());
            return true;
        }

        public static bool Opp(Game g, Thing thing, Pointer offset, Vector vector)
        {
            if (g.ReadDirection(thing, offset, vector))
            {
                vector.CopyFrom(vector.Opposite());
                return true;
            }
            return false;
        }

        public static bool Rnd(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(g.Rnd());
            return true;
        }

        public static bool RndNE(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(g.RndNE());
            return true;
        }

        public static bool RndNS(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(g.RndNS());
            return true;
        }

        public static bool RndP(Game g, Thing thing, Pointer offset, Vector vector)
        {
            if (g.ReadDirection(thing, offset, vector))
            {
                vector.CopyFrom(g.RndP(vector));
                return true;
            }
            return false;
        }

        public static bool Seek(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(g.Seek(thing.Location));
            return true;
        }

        public static bool South(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(Vector.South());
            return true;
        }

        public static bool West(Game g, Thing thing, Pointer offset, Vector vector)
        {
            vector.CopyFrom(Vector.West());
            return true;
        }
    }
}
